# coding=utf-8

a = max(1, 2)  # 可传入多个参数
print(bool(a))

print(hex(10))
print(max(100, 200, 1, 222, 22))

import math


def quadratic(a, b, c):
    p = b * b - 4 * a * c
    if p >= 0 and a != 0:
        x1 = (-b + math.sqrt(p)) / (2 * a)
        x2 = (-b - math.sqrt(p)) / (2 * a)
        return x1, x2
    else:
        return 'Wrong Number！'


def power(x, n=2):
    s = 1
    while n > 0:
        n = n - 1
        s = s * x
    return s


def add_end(L=None):
    if L is None:
        L = []
    L.append('END')
    return L


print(add_end())


def calc(*numbers):
    """

    :rtype : object
    """
    sum = 0
    for n in numbers:
        sum = sum + n * n
    return sum


print(calc(100))


# 可变参数允许你传入0个或任意个参数，这些可变参数在函数调用时自动组装为一个tuple 而关键字参数允许你传入0个或任意个含参数名的参数，这些关键字参数在函数内部自动组装为一个dict。
def person(name, age, **kw):
    """

    :rtype : object
    """
    print('name:', name, 'age:', age, 'other:', kw)


extra = {'city': 'Beijing', 'job': 'Engineer'}
person('Jack', 24, city=extra['city'], job=extra['job'])
person('Jack', 24, **extra)  # 简化写法


# 命名关键字参数
def personA(name, age, **kw):
    if 'city' in kw:
        # 有city参数
        pass
    if 'job' in kw:
        # 有job参数
        pass
    print('name:', name, 'age:', age, 'other:', kw)


personA('Jack', 24, **extra)


# 比如定义一个函数，包含上述若干种参数：
def f1(a, b, c=0, *args, **kw):
    """

    :rtype : object
    """
    print('a =', a, 'b =', b, 'c =', c, 'args =', args, 'kw =', kw)


def f2(a, b, c=0, *, d, **kw):
    print('a =', a, 'b =', b, 'c =', c, 'd =', d, 'kw =', kw)


f1(1, 2)
f1(1, 2, c=3)
f1(1, 2, 3, 'a', 'b')
f1(1, 2, 3, 'a', 'b', x=99)
f2(1, 2, d=99, ext=None)

print(list(range(1, 100, 2)))

L = [1, 2, 3, 4, 5, 6, 7, 8, 9]
print(L)
print(L[::1])
print(L[::-1])  # 在此插入代码
